<template>
	<view class="box1">
		<Title :txt="i18n.sbxq" :showback="true"></Title>
		<view class="">
			<view class="dash1 fcs mgt20">
				<image :src="active>=0?'../../static/activedash.png':'../../static/dash.png'" mode=""></image>
				<view class="small" ></view>
				<image :src="active>=1?'../../static/activedash.png':'../../static/dash.png'" mode=""></image>
				<view class="small"></view>
				<image :src="active>=2?'../../static/activedash.png':'../../static/dash.png'" mode="" ></image>
				<view class="small"></view>
				<image :src="active>=3?'../../static/activedash.png':'../../static/dash.png'" mode="" ></image>
				<view class="small"></view>
				<image :src="active==4?'../../static/activedash.png':'../../static/dash.png'" mode="" ></image>
			</view>
			<view class="dash fsc mt14 f12">
				<view :class="[active>=0?'color-theme':'white']" >{{i18n.goum}}</view>
				
				<view :class="[active>=1?'color-theme':'white']" >{{i18n.sjz}}</view>
				
				<view :class="[active>=2?'color-theme':'white']" >{{i18n.fzq}}</view>
				
				<view :class="[active>=3?'color-theme':'white']">{{i18n.wkz}}</view>
				<view :class="[active>=4?'color-theme':'white']">
					{{i18n.jiesu}}
				</view>
			</view>
			<view class="px15 mt15">
				<view class="bgcc bor5 px10 f12">
					<view class="border2 py12 f14 white">{{i18n.ccfz}}</view>
					<view v-for="(oitem,oindex) in orderInfo.mineOrderCoinList" :key="oindex" class="fsb mb15 mt15">
						<view class="color-gray">{{i18n.zcc}}{{oitem.coin}}</view>
						<view class="color-theme">{{oitem.sumIncome}}</view>
					</view>
					<view class="fsb mb15">
						<view class="color-gray">{{i18n.yfz}}</view>
						<view class="color-yellow">{{hasFzStorageCapacity}}T</view>
					</view>
					<view class="fsb pb15">
						<view class="color-gray">{{i18n.ddzccrl}}</view>
						<view class="color-white">{{sumStorageCapacity}}T</view>
					</view>
				</view>
				<view class="bgcc bor5 px10 f12 mt10 white">
					<view class="border2 py12 f14">{{i18n.gmxx}}</view>
					<view class="fsb mb15 mt15">
						<view class="color-gray">{{i18n.gmsl}}</view>
						<view>{{number}}</view>
					</view>
					<view class="fsb mb15">
						<view class="color-gray">{{i18n.ddzj}}</view>
						<view>{{sumPriceUsdt}}USDT</view>
					</view>
					<view class="fsb mb15">
						<view class="color-gray">{{i18n.ddh}}</view>
						<view>{{orderId}}</view>
					</view>
					<view class="fsb pb15">
						<view class="color-gray">{{i18n.xdsj}}</view>
						<view>{{createDate}}</view>
					</view>
				</view>
				<view class="bgcc bor5 px10 f12 mt10 white">
					<view class="border2 py12 f14">{{i18n.sbxx}}</view>
					<view class="fsb mb15 mt15">
						<view class="color-gray">{{i18n.sbmc}}</view>
						<view>{{name}}</view>
					</view>
					<view class="fsb mb15">
						<view class="color-gray">{{i18n.sbccrl}}</view>
						<view>{{storageCapacity}}T</view>
					</view>
					<view class="fsb mb15">
						<view class="color-gray">{{i18n.sjq}}</view>
						<view>{{shelfDay}}{{i18n.tian}}</view>
					</view>
					<view class="fsb mb15">
						<view class="color-gray">{{i18n.fzq}}</view>
						<view>{{packagingDay}}{{i18n.tian}}</view>
					</view>
					<view class="fsb mb15">
						<view class="color-gray">{{i18n.wkq}}</view>
						<view>{{miningDay}}{{i18n.tian}}</view>
					</view>
					<view class="fsb mb15">
						<view class="color-gray">{{i18n.glffw}}</view>
						<view>{{serviceCharge*100}}%</view>
					</view>
					<view class="fsb mb15">
						<view class="color-gray">{{i18n.cling}}</view>
						<view>{{output}}/{{i18n.tian}}</view>
					</view>
					<view class="fsb mb15">
						<view class="color-gray">{{i18n.ddf}}</view>
						<view>{{orderInfo.dkFee}}USDT/{{i18n.yue}}</view>
					</view>
					<view class="fsb mb15">
						<view class="color-gray">{{i18n.zy}}</view>
						<view>{{pledge}}</view>
					</view>
					<view class="fsb pb15">
						<view class="color-gray">{{i18n.gasf}}</view>
						<view>{{gasFee}}</view>
					</view>
				</view>
				<!--  v-if="active==4"  -->
				<view v-if="active>=3" class=" white mt22 py11 bor5 text--center" @click="applyRefund" :class="(applyState==3||applyState==4)?'bgcc':'bg-theme'">{{applyState==1?i18n.sqzy:(applyState==2?i18n.zyytj:(applyState==4?i18n.zybj:i18n.yth))}}</view>
			</view>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			status: 0,
			active:0,
			isApply:0,
			orderId:'',
			createDate:"",
			name:"",
			storageCapacity:"",
			number:"",
			sumPriceUsdt:"",
			sumStorageCapacity:"",
			hasFzStorageCapacity:"",
			shelfDay:"",
			packagingDay:"",
			miningDay:"",
			serviceCharge:"",
			id:"",
			output:'',
			pledge:'',
			gasFee:'',
			orderInfo:{},
			applyState:0
		};
	},
	onLoad(options) {
		this.orderId=options.id
	},
	computed:{
		i18n() {
			return this.$t('home');
		}
	},
	onShow() {
		let params={
			orderId:this.orderId
		}
		this.$http.post("index.getOrderInfo",params).then(res=>{
			this.orderInfo = res.data
			this.active=res.data.status
			this.createDate=res.data.createDate
			this.name=res.data.name
			this.storageCapacity=res.data.storageCapacity
			this.number=res.data.number
			this.sumPriceUsdt=res.data.sumPriceUsdt
			this.sumStorageCapacity=res.data.sumStorageCapacity
			this.hasFzStorageCapacity=res.data.hasFzStorageCapacity
			this.shelfDay=res.data.shelfDay
			this.packagingDay=res.data.packagingDay
			this.miningDay=res.data.miningDay
			this.serviceCharge=res.data.serviceCharge
			this.applyState = res.data.jyStatus //1:正常挖矿，2:申请解压中,3:申请通过,4:申请被拒
			this.id=res.data.id
			if(res.data.hohoMineListCoin.length==1){
				this.output = res.data.hohoMineListCoin[0].miningEfficiency +res.data.hohoMineListCoin[0].coin
				this.pledge = res.data.hohoMineListCoin[0].pledgeCount +res.data.hohoMineListCoin[0].coin
				this.gasFee = res.data.hohoMineListCoin[0].gasCount +res.data.hohoMineListCoin[0].coin
			}else{
				let newpledgeArr = [],minerArr = [],gasArr =[]
				res.data.hohoMineListCoin.forEach((item,index)=>{
					minerArr.push(item.miningEfficiency+item.coin)
					newpledgeArr.push(item.pledgeCount+item.coin)
					gasArr.push(item.gasCount+item.coin)
				})
				this.output = minerArr.join('+')
				this.pledge = newpledgeArr.join('+')
				this.gasFee = gasArr.join('+')
			}
		})
	},
	methods: {
		applyRefund(){
			if(this.applyState==1){
				// 申请退款
				this.$http.post("index.returnZyCoin",{orderId:this.orderId}).then(res=>{
					uni.showToast({
						title:this.$t('home').zycg,
						icon:'none'
					})
					this.applyState =2
				})
			}
		},
		gotoKuanDetail(){
			uni.navigateTo({
				url:"../index/equipdetail?id="+this.id
			})
		}
	}
};
</script>

<style lang="less">
.box1 {
	padding-bottom: 80rpx;
	.list {
		width: 642rpx;
		height: 252rpx;
		opacity: 1;
		background: #ffffff;
		border-radius: 24rpx;
		margin-left: auto;
		margin-right: auto;
		padding: 36rpx;
		position: relative;
		.po {
			position: absolute;
			right: 0;
			bottom: 0;
		}
	}
	.dash1 {
		padding: 0 54rpx;
		
		image{
			width: 36rpx;
			height: 36rpx;
			
		}
		.small{
			width: 116rpx;
			height: 2rpx;
			background-color: #586471;
		}
	}
	.dash{
		padding: 0 46rpx;
	}
	.itembox{
		width: 690rpx;
		padding: 0 0rpx 36rpx 0rpx;
		border-bottom: 2rpx solid #ccc;
		margin-left: auto;
		margin-right: auto;
	}
	.end{
	}
}
</style>
